#include <func.h>
#include <netinet/in.h>

int main(int argc, char* argv[])
{
    if(argc != 2)
        error(1, 0, "Usage: %s url",argv[0]);

    struct addrinfo* res;
    if(getaddrinfo(argv[1], NULL, NULL, &res) != 0)
        error(1, errno, "getaddrinfo");

    while(res != NULL)
    {
        if(res->ai_family == AF_INET)
        {
            struct sockaddr_in* a = (struct sockaddr_in*)res->ai_addr;
            printf("%s IP: %s\n", argv[1], inet_ntoa(a->sin_addr));
        }
        res = res->ai_next;
    }
    return 0;

}

